﻿using System.ServiceModel;

namespace FlightSearchServer
{
    [ServiceContract]
    public interface IRegistartionService
    {
        [OperationContract]
        void RegisterAlliance(string alliance, string uri);
    }

    [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
    internal class RegistartionService : IRegistartionService
    {
        private readonly SearchManager searchManager;

        public RegistartionService(SearchManager searchManager)
        {
            this.searchManager = searchManager;
        }

        public void RegisterAlliance(string alliance, string uri)
        {
            searchManager.AddAlliance(new FlightAlliance
            {
                Name = alliance,
                Uri = uri,
            });
        }
    }
}
